package com.tywj.panda.customer.common.view.base

import android.content.res.Resources
import android.os.Bundle
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LifecycleOwner
import com.tywj.lib.businessweak.view.IBaseView
import com.tywj.lib.core.common.view.BaseActivity
import me.jessyan.autosize.AutoSizeCompat

/**
 * @desc 基类Activity
 * @author June Yang
 * @date 2020/5/8
 */
abstract class MyBaseActivity : BaseActivity(), IBaseView {

    private lateinit var baseView: IBaseView

    override fun initVariable(savedInstanceState: Bundle?) {
        super.initVariable(savedInstanceState)

        baseView = BaseViewImpl(supportFragmentManager, this)
    }

    override fun shortToast(msg: CharSequence) {
        baseView.shortToast(msg)
    }

    override fun shortToast(id: Int) {
        baseView.shortToast(id)
    }

    override fun longToast(msg: CharSequence) {
        baseView.longToast(msg)
    }

    override fun longToast(id: Int) {
        baseView.longToast(id)
    }

    override fun showLoadingDialog(msg: String) {
        baseView.showLoadingDialog(msg)
    }

    override fun showLoadingDialog(id: Int) {
        baseView.showLoadingDialog(id)
    }

    override fun dismissLoadingDialog() {
        baseView.dismissLoadingDialog()
    }

    override fun getLifecycleOwner(): LifecycleOwner {
        return baseView.getLifecycleOwner()
    }

    override fun getFragmentManagerInstance(): FragmentManager {
        return baseView.getFragmentManagerInstance()
    }


    override fun getResources(): Resources {
        // 解决所有屏幕适配失效的问题
        AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources()))
        return super.getResources()
    }
}